import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Date;


public class SqlTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		
		testJdbc();
		
	}

	private static void testJdbc() throws Exception {
		
		Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@172.24.40.134:1521:cfaoconv", 
				"bendev", "bendev");
		Statement stmt = conn.createStatement();
		String sql = 
			"select distinct di.*" +
			" from imaging.document_image di" +
			" inner join imaging.document_image_key dik" +
			" on di.document_image_id = dik.document_image_id" +
			" and dik.entity_id is null and dik.key_value is null";
		long start = System.currentTimeMillis();

		ResultSet rs = stmt.executeQuery(sql);
		int rowCount = 0;
		while (rs.next()) {
			rowCount++;
			if (rowCount % 100 == 0)
				System.out.println("rowCount: " + rowCount);
		}
		
		long end = System.currentTimeMillis();
		
		System.out.println(rowCount + " rows selected in " + (end - start)/1000 + " sec.");
		
		rs.close();
		stmt.close();
		conn.close();		
	}
}
